package com.atguigu.daijia.driver.controller;

import com.atguigu.daijia.common.login.GuiguLogin;
import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.driver.service.CosService;
import com.atguigu.daijia.model.vo.driver.CosUploadVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/** 腾讯云cos上传接口管理
 * @author 谢忠涵7
 */
@Slf4j
@Tag(name = "腾讯云cos上传接口管理")
@RestController
@RequestMapping(value="/cos")
@SuppressWarnings({"unchecked", "rawtypes"})
public class CosController {

    @Autowired
    private CosService cosService;
    /**
     * @description: 上传司机的认证图片到腾讯云
     * @author: xiaoxie
     * @date: 2024/10/24 21:29
     * @param: [file, path] 文件,腾讯云的存储地址
     * @return: CosUploadVo 上传信息VO对象
     **/
    @Operation(summary = "上传")
    @GuiguLogin
    @PostMapping("/upload")
    public Result<CosUploadVo> upload(@RequestPart("file") MultipartFile file
             , @RequestParam(name = "path", defaultValue = "auth") String path) {
        CosUploadVo result =  cosService.uploadFile(file,path);
        return Result.ok(result);
    }
}

